//
//  HNSH_TZExchangeRecordCell.m
//  HNSH_SingleProject
//
//  Created by 李宇廷 on 2023/6/14.
//

#import "HNSH_TZExchangeRecordCell.h"

@interface HNSH_TZExchangeRecordCell ()

/* bgView */
@property (nonatomic, strong) UIView *bgView;
/* titleLabel */
@property (nonatomic, strong) UILabel *titleLabel;
/* timeLabel */
@property (nonatomic, strong) UILabel *timeLabel;
/* statusLabel */
@property (nonatomic, strong) UILabel *statusLabel;
/* moneyLabel */
@property (nonatomic, strong) UILabel *moneyLabel;
/* lineView */
@property (nonatomic, strong) UIView *lineView;


@end

@implementation HNSH_TZExchangeRecordCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor appBGColor];
        [self configView];
    }
    return self;
}

- (void)setModel:(HNSH_TZExchangeRecordModel *)model {
    _model = model;
    if (model.income) {
        self.moneyLabel.text = [NSString stringWithFormat:@"+%@",model.amount];
        self.moneyLabel.textColor = [UIColor appGreenColor];
    } else {
        self.moneyLabel.text = [NSString stringWithFormat:@"-%@",model.amount];
        self.moneyLabel.textColor = [UIColor appGreenColor];
    }
    
    self.titleLabel.text = model.remark;
    self.timeLabel.text = model.create_time;
}

- (void)configView {
    [self addSubview:self.bgView];
    [self.bgView addSubview:self.statusLabel];
    [self.bgView addSubview:self.moneyLabel];
    [self.bgView addSubview:self.titleLabel];
    [self.bgView addSubview:self.timeLabel];
    [self.bgView addSubview:self.lineView];
        
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.top.mas_equalTo(11);
        make.height.mas_equalTo(20);
    }];
    
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.top.mas_equalTo(33);
        make.height.mas_equalTo(17);
    }];
    
    [self.statusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-16);
        make.centerY.equalTo(self.titleLabel.mas_centerY);
        make.height.mas_equalTo(17);
    }];
    
    [self.moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-16);
        make.centerY.equalTo(self.timeLabel.mas_centerY);
        make.height.mas_equalTo(17);
    }];
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.mas_equalTo(0);
        make.height.mas_equalTo(1);
    }];
}


#pragma mark lazy
- (UIView *)bgView {
    if (!_bgView) {
        _bgView = [[UIView alloc]initWithFrame:CGRectMake(10, 0, kScreenWidth-20, 62)];
        _bgView.backgroundColor = [UIColor appWhiteLabelColor];
    }
    return _bgView;
}

- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc]init];
        _titleLabel.text = @"完成任务获得";
        _titleLabel.textColor = [UIColor appBlackLabelColor];
        _titleLabel.font = [UIFont systemFontOfSize:14];
    }
    return _titleLabel;
}

- (UILabel *)timeLabel {
    if (!_timeLabel) {
        _timeLabel = [[UILabel alloc]init];
        _timeLabel.text = @"2022-09-09  20:17:53";
        _timeLabel.textColor = [UIColor appGrayLabelColor];
        _timeLabel.font = [UIFont systemFontOfSize:12];
    }
    return _timeLabel;
}

- (UILabel *)moneyLabel {
    if (!_moneyLabel) {
        _moneyLabel = [[UILabel alloc]init];
        _moneyLabel.text = @"+3.00";
        _moneyLabel.textColor = [UIColor appGreenColor];
        _moneyLabel.font = [UIFont boldSystemFontOfSize:16];
    }
    return _moneyLabel;
}

- (UILabel *)statusLabel {
    if (!_statusLabel) {
        _statusLabel = [[UILabel alloc]init];
        _statusLabel.text = @"";
        _statusLabel.textColor = [UIColor appGreenColor];
        _statusLabel.font = [UIFont boldSystemFontOfSize:12];
    }
    return _statusLabel;
}

- (UIView *)lineView {
    if (!_lineView) {
        _lineView = [[UIView alloc]init];
        _lineView.backgroundColor = [UIColor colorWithHexString:@"#F3F3F3"];
    }
    return _lineView;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
